package org.example.myleet.p399;

import org.example.myleet.Utils.Assert;

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        Solution solution = new Solution();
        Assert.isTrue(Assert.isPass(new double[]{6.00000,0.50000,-1.00000,1.00000,-1.00000}, solution.calcEquation(parse(new String[][]{{"a", "b"}, {"b", "c"}}), new double[]{2.0, 3.0}, parse(new String[][]{{"a", "c"},{"b", "a"},{"a", "e"},{"a", "a"},{"x", "x"}}))));
        Assert.isTrue(Assert.isPass(new double[]{3.75000,0.40000,5.00000,0.20000}, solution.calcEquation(parse(new String[][]{{"a", "b"}, {"b", "c"}, {"bc", "cd"}}), new double[]{1.5, 2.5, 5.0}, parse(new String[][]{{"a", "c"},{"c", "b"},{"bc", "cd"},{"cd", "bc"}}))));
        Assert.isTrue(Assert.isPass(new double[]{0.50000,2.00000,-1.00000,-1.00000}, solution.calcEquation(parse(new String[][]{{"a", "b"}}), new double[]{0.5}, parse(new String[][]{{"a","b"},{"b","a"},{"a", "c"},{"x", "y"}}))));
        Assert.isTrue(Assert.isPass(new double[]{6.0000,0.5000,-1.0000,1.0000,-1.0000}, solution.calcEquation(parse(new String[][]{{"a", "b"},{"b", "c"},{"a", "c"}}), new double[]{2.00000,3.00000,6.00000}, parse(new String[][]{{"a","c"},{"b","a"},{"a", "e"},{"a", "a"},{"x", "x"}}))));
        Assert.isTrue(Assert.isPass(new double[]{6.0000,3.0000,-1.0000,1.0000,-1.0000,-1.0000}, solution.calcEquation(parse(new String[][]{{"a", "b"},{"b", "c"},{"a", "c"},{"d", "e"}}), new double[]{2.00000,3.00000,6.00000,1.0000}, parse(new String[][]{{"a","c"},{"b","c"},{"a", "e"},{"a", "a"},{"x", "x"},{"a", "d"}}))));
    }

    private static List<List<String>> parse(String[][] arr) {
        List<List<String>> list = new ArrayList<>();
        for (String[] ss : arr) {
            List<String> l = new ArrayList<>();
            for (String s : ss) {
                l.add(s);
            }
            list.add(l);
        }
        return list;
    }
}
